<?php

/**
 * Enter description here...
 *
 */
class My_Validate_Password extends Zend_Validate_Abstract
{
    const INVALID_PASSWORD = 'invalidPassword';

    const INVALID_CONTEXT = 'invalidContext';

    protected $_messageTemplates = array(
        self::INVALID_PASSWORD => "Passwords does not match",
        self::INVALID_CONTEXT => 'Context column not set in validator'
    );

    /**
     *
     * @var string
     */

    private $_context_key;

    /**
     * Validator kontroluje zda hodnota odpovida tomuto policku ve formulari
     *
     * @param string $context_key
     */

    public function __construct($context_key)
    {
        $this->_context_key = $context_key;
    }

    /**
     * Enter description here...
     *
     * @param string $value
     * @return boolean
     */
    public function isValid($value, $context = null)
    {
        if (!isset($context[$this->_context_key]))
        {
            $this->_error(self::INVALID_CONTEXT);
            return false;
        }

        if ($context[$this->_context_key] != $value)
        {
            $this->_error(self::INVALID_PASSWORD);
            return false;
        }


        return true;
    }

}
